package at.main.gui;

import at.main.android.Graphics;
import at.main.util.ManagerAudio;
import at.main.util.ManagerFont;

public class MenuPlaying {
	public static final int k_continePlaying = 0;
	public static final int k_menugame = 1;	
	public static final int k_option = 2;
	public static final int k_exitgame = 3;
	
	public int iSelectMenu = 0;
	public final String k_s0= "Chơi tiếp";
	public final String k_s1= "Về menu chính";
	public final String k_s2= "Âm thanh";
	public final String k_s3= "Thoát game";
	public ManagerAudio audio = null;
	public ManagerAudio audio1 = null;
	
	
	public  MenuPlaying() {
		// TODO Auto-generated constructor stub
	}

	public void paint(Graphics g) {		
		g.setColor(0x87CEFF);
		g.fillRect(0, 0, MyCanvas.iWidth, MyCanvas.iHeight);		
		ManagerFont.drawString(g, k_s0, MyCanvas.iWidth/2 - k_s0.length()/2, MyCanvas.iHeight/4, 2, ((0-iSelectMenu)==0?1:2));
		ManagerFont.drawString(g, k_s1, MyCanvas.iWidth/2 - k_s1.length()/2, MyCanvas.iHeight/4+20, 2, ((1-iSelectMenu)==0?1:2));
		ManagerFont.drawString(g, k_s2, MyCanvas.iWidth/2 - k_s2.length()/2, MyCanvas.iHeight/4+40, 2, ((2-iSelectMenu)==0?1:2));
		ManagerFont.drawString(g, k_s3, MyCanvas.iWidth/2 - k_s3.length()/2, MyCanvas.iHeight/4+60, 2, ((3-iSelectMenu)==0?1:2));
	}

	public void update() {
//		if(audio !=null && SoundPage.isSound)
//			audio.playSound();
		// Up
		if (MyCanvas.keyHold[2]) {
			iSelectMenu--;
			if(iSelectMenu < 0)
				iSelectMenu = 3;
		}
		if (MyCanvas.keyHold[8]) {
			iSelectMenu++;
			if(iSelectMenu > 3)
				iSelectMenu = 0;
		}
		if(MyCanvas.keyHold[5]){
			if(audio !=null)
				audio.stopSound();
			switch (iSelectMenu) {			
			case k_continePlaying:
				PlayGame.isPause = false;
				MyCanvas.iCurrentPage = MyCanvas.k_PlayGame;
				MyCanvas.clearInput();
				break;
			case k_menugame:
				MyCanvas.clearInput();
				MyCanvas.iCurrentPage = MyCanvas.k_MenuPage;				
				break;
			case k_option:
				MyCanvas.iCurrentPage = MyCanvas.k_OptionGame;
				MyCanvas.clearInput();
				break;
			case k_exitgame:	
				MyCanvas.iCurrentPage = MyCanvas.k_ExitGame;
				MyCanvas.clearInput();
				break;		
			default:				
				break;
			}
			MyCanvas.clearInput();			
		}
		MyCanvas.clearInput();
	}
}
